package com.levy.contronller.javaWeb.webservice.client.axisTest;

import javax.xml.namespace.QName;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.types.Schema;

/**
 * lib.rar  为 axis1.4 包

 要把axis1.4的包都导进去,否则会有很多错误的，导进去就可以运行了.

 String theRegionCode = "31124"; //为城市代码,可以通过WEB服务获取

 2400多个城市5日天气预报 WEB服务
 Endpoint: http://www.webxml.com.cn/WebServices/WeatherWS.asmx
 Disco: http://www.webxml.com.cn/WebServices/WeatherWS.asmx?disco
 WSDL: http://www.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl

 */
public class AxisForWeatherTest {

	public static void main(String[] args) {
		try {
			String theRegionCode = "31124";

			String endpoint = "http://www.webxml.com.cn/WebServices/WeatherWS.asmx";

			Service service = new Service();

			Call call = (Call) service.createCall();
			call.setTargetEndpointAddress(new java.net.URL(endpoint));

			call.setOperationName(new QName("http://WebXml.com.cn/","getSupportCityDataset"));

			call.addParameter(new QName("http://WebXml.com.cn/","theRegionCode"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
			
			call.setReturnType(org.apache.axis.encoding.XMLType.XSD_SCHEMA);
			
			call.setUseSOAPAction(true);
			call.setSOAPActionURI("http://WebXml.com.cn/getSupportCityDataset");

			Schema result =  (Schema)call.invoke(new Object[]{"31124"});
			
			for (int i = 0; i < result.get_any().length; i++) {
				System.out.println(result.get_any()[i]);				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
